package com.nazca.tvremote.event;

import org.json.JSONException;
import org.json.JSONObject;

import android.view.MotionEvent;


public final class RemoteMotionEvent extends RemoteEvent {

	//MotionEvent.obtain(downTime, eventTime, action, x, y, metaState)
	private MotionEvent mEvent;
	private float mDstX;
	private float mDstY;
	
	public RemoteMotionEvent(MotionEvent e, float dstX, float dstY){
		mEvent = e;
		mDstX = dstX;
		mDstY = dstY;
	}
	
	@Override
	public String toString() {
		
		JSONObject json = new JSONObject();
		try {
			json.put("EventType", "MotionEvent");
		
			JSONObject event = new JSONObject();
			json.put("Event", event);
			
			event.put("downTime", mEvent.getDownTime());
			event.put("eventTime", mEvent.getEventTime());
			event.put("action", mEvent.getAction());
			event.put("x", String.valueOf(mDstX));
			event.put("y", String.valueOf(mDstY));
			event.put("metaState", mEvent.getMetaState());
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return json.toString();
	}
	
}
